


import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:oral_cloud/config/constant.dart';
import 'package:oral_cloud/config/resource_mananger.dart';
import 'package:oral_cloud/config/router_manger.dart';
import 'package:oral_cloud/model/patient.dart';
import 'package:oral_cloud/ui/widget/global_widget.dart';

import 'image.dart';

class PatientItemWidget extends StatelessWidget {
  final Patient patient;
  final int index;
  PatientItemWidget(this.patient, {this.index});




  @override
  Widget build(BuildContext context) {
    return Material(
      color: Theme.of(context).scaffoldBackgroundColor,
      child: InkWell(
        onTap: () async {
          print('onTap===>patient=$patient');
          Navigator.of(context).pushNamed(RouteName.patient_details,arguments: patient);
          },
        child: Container(
            padding: EdgeInsets.only(
                left: ScreenUtil.getInstance().setWidth(44),
                top: ScreenUtil.getInstance().setHeight(48),
                bottom: ScreenUtil.getInstance().setHeight(42),
                right: ScreenUtil.getInstance().setWidth(50),
            ),
            child: Row(
              mainAxisSize: MainAxisSize.max,
              children: [

                Stack(
                  alignment: Alignment.bottomRight,
                  children: [
                    ClipOval(
                      child: WrapperImage(
                        imageType: ImageType.normal,
                        url: patient.avatar,
                        placeholder: patient.sex==1?'male_default.png':'female_default.png',
                        height: ScreenUtil.getInstance().setWidth(126),
                        width: ScreenUtil.getInstance().setWidth(126),
                      ),
                    ),
                    Image.asset(ImageHelper.wrapAssets(patient.sex==1?'male.png':'female.png'),
                      width: ScreenUtil.getInstance().setWidth(45),
                      height: ScreenUtil.getInstance().setWidth(45),
                    )
                  ],
                ),

                Expanded(
                  child: Padding(
                    padding: EdgeInsets.only(left: ScreenUtil.getInstance().setWidth(66)),
                    child: Column(
                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: [
                        Text(
                          '姓名:${patient.username}',
                          style: TextStyle(
                            fontWeight: FontWeight.bold,
                            color: Color(MYColors.textHighlightColor),
                            fontSize: FontSize.fontSizeL,
                          ),
                        ),
                        SizedBox(height: ScreenUtil.getInstance().setHeight(26),),
                        Row(
                          mainAxisAlignment: MainAxisAlignment.end,
                          mainAxisSize: MainAxisSize.max,
                          children: [
                            Expanded(
                              child: NormalText('患者编号:${patient.patientNo}'),
                            ),
                            Image.asset(ImageHelper.wrapAssets('right_enter.png'),
                              width: ScreenUtil.getInstance().setHeight(26),
                              height: ScreenUtil.getInstance().setHeight(26),
                            )
                          ],
                        ),
                        SizedBox(height: ScreenUtil.getInstance().setHeight(22),),

                        Row(
                          children: [
                            NormalText('出生日期:${patient.birthDate}'),
                            Padding(
                              padding: EdgeInsets.only(left: ScreenUtil.getInstance().setWidth(29)),
                              child: NormalText('录入日期:${patient.recordDate}'),
                            ),
                          ],
                        ),
                      ],
                    ),
                  ),
                ),
              ],
            ),
            decoration: BoxDecoration(
              border: Border(
                bottom: BorderSide(
                  width: 10,
                  color: Color(0xffeef5f9),
                ),
              ),
            )),
      ),
    );
  }


}


